package aod.android.com.bernay.util;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import aod.android.com.bernay.R;

/**
 * @author crated by zhixianuanyang on 2019/4/7 14:48
 * @Email jamesKing0812@gmail.com
 */
public class Utils {

    //选中的图片
    public static List<String> selectedList = new ArrayList<>();

    public static int dip2px(Context context, float dipValue){
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int)(dipValue * scale + 0.5f); //+0.5是为了向上取整       
    }

    public static int px2dip(Context context, float pxValue){
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int)(pxValue / scale + 0.5f);//+0.5是为了向上取整      
    }
    public static View getTabView0(Context context,String tabName) {
        LayoutInflater mInflater = LayoutInflater.from(context);
        View view = mInflater.inflate(R.layout.left_tab_view, null);
        TextView leftTextView = view.findViewById(R.id.tab_text_left);
        leftTextView.setText(tabName);
        return view;
    }

    public static View getTabView1(Context context,String tabName) {
        LayoutInflater mInflater = LayoutInflater.from(context);
        View view = mInflater.inflate(R.layout.right_tab_view, null);
        TextView rightTextView = view.findViewById(R.id.tab_text_right);
        rightTextView.setText(tabName);
        return view;
    }

    /**
     * 拨打电话（跳转到拨号界面，用户手动点击拨打）
     * @param phoneNum
     */
    public static void callPhone(Context mContext,String phoneNum) {
        Intent intent = new Intent(Intent.ACTION_DIAL);
        Uri data = Uri.parse("tel:" + phoneNum);
        intent.setData(data);
        mContext.startActivity(intent);
    }
}
